package com.arvato.right.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.arvato.minipro.bean.bean_dto.common.PageData;
import com.arvato.minipro.bean.bean_dto.common.Query;
import com.arvato.right.bean.bean_do.WxworkRightPassDo;
import com.arvato.right.bean.bean_vo.WxworkRightPassVo;
import com.arvato.right.mapper.WxworkRightPassMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;


@Service
@Transactional
public class WxworkRightPassService {
	@Autowired
	private WxworkRightPassMapper wxworkRightPassMapper;
	
	/**
	 * 插入免检资源
	 * @param passDo
	 * @return
	 */
	public int insert(WxworkRightPassDo passDo) {
		int row = wxworkRightPassMapper.insert(passDo);
		return row;
	}
	
	/**
	 * 查询免检资源列表(分页)
	 * @param query
	 * @return
	 */
	public PageData listPassByQuery(Query query, Integer pageNum, Integer pageSize) {
		// 设置分页参数
		PageHelper.startPage(pageNum, pageSize);
		// 执行查询
		List<WxworkRightPassVo> userList = wxworkRightPassMapper.listPassByQuery(query);
		// 得到结果
		PageInfo<WxworkRightPassVo> pageInfo = new PageInfo<WxworkRightPassVo>(userList);
		List<WxworkRightPassVo> list = pageInfo.getList();
		PageData data = new PageData(pageInfo.getTotal(), list);
		return data;
	}
	
	/**
	 * 查询免检资源列表(不分页)
	 * @param query
	 * @return
	 */
	public List<WxworkRightPassVo> listPassByQuery(Query query) {
		List<WxworkRightPassVo> userList = wxworkRightPassMapper.listPassByQuery(query);
		return userList;
	}
	
	/**
	 * 删除免检URL
	 * @param valueOf
	 * @return
	 */
	public int delete(String id) {
		int row = wxworkRightPassMapper.delete(id);
		return row;
	}
	
	
}
